<?php
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'basic';
$return=array();
$tabs=array(
	array('op'=>'basic','title'=>'基本参数设置'),
	array('op'=>'message_tpl','title'=>'模版消息设置'),
	array('op'=>'sms_tpl','title'=>'短信模版设置'),
	//array('op'=>'diy','title'=>'自定义菜单'),
);
if($_RQ['op']=='basic'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$this->plugin_setting('basic',$postdata);
		exi('设置成功');
	}
	$bankuai =array(
		array('title'=>'租地种植','img'=>'../core/resource/images/diy/icon/icon-1.png','action'=>'jy_farmer/lclassify/'),
		array('title'=>'家畜领养','img'=>'../core/resource/images/diy/icon/icon-2.png','action'=>'jy_farmer/aclassify/'),
		array('title'=>'领券中心','img'=>'../core/resource/images/diy/icon/icon_coupon.png','action'=>'jy_weishop/coupon.index/'),
		array('title'=>'农场监控','img'=>'../core/resource/images/diy/icon/icon-live.png','action'=>'jy_live/list/'),
		array('title'=>'公司简介','img'=>'../core/resource/images/diy/icon/icon-3.png','action'=>'jy_farmer/jianjie/'),
	);
	$footernav =array(
		array('title'=>'首页','icon'=>'icon-shouye','action'=>'jy_farmer/index/'),
		array('title'=>'土地','icon'=>'icon-ditu','action'=>'jy_farmer/lclassify/'),
		array('title'=>'果树','icon'=>'icon-haoping','action'=>'jy_farmer/gclassify/'),
		array('title'=>'家禽','icon'=>'icon-zidingyileimu','action'=>'jy_farmer/aclassify/'),
		array('title'=>'种子','icon'=>'icon-favorite','action'=>'jy_farmer/seed/'),
		array('title'=>'我的','icon'=>'icon-wo1','action'=>'jy_farmer/myhome/'),
	);	
	$plugins =$this->plugins();
	$return['item']=$this->plugin_setting('basic');
	$return['item']['demofooternav'] = $footernav;
	$return['item']['bankuai']=$return['item']['bankuai']?$return['item']['bankuai']:$bankuai;
	$return['item']['footernav']=$return['item']['footernav']?$return['item']['footernav']:$footernav;
	$return['item']['plugins']=$return['item']['plugins']?$return['item']['plugins']:$plugins[1]['list'];
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'tabs'=>$tabs,
		'edit_tab'=>true,
		'edits'=>array(
			array(
				'title'=>'基本信息',
				'list'=>array(
					array('type'=>'string','title'=>'网站名称','name'=>'title'),
					array('type'=>'image','title'=>'网站logo','name'=>'logo'),
					array('type'=>'switch','title'=>'支持美丽天天秒？','name'=>'jy_twojiup','help'=>'开启后，农场消费（种植，领养等等）都按【美丽天天秒】的分销规则'),
					array('type'=>'switch','title'=>'开启独立商品','name'=>'is_onegoods','help'=>'开启后，商品独立化'),
					array('type'=>'string','title'=>'分享标题','name'=>'share_title'),
					array('type'=>'image','title'=>'分享图片','name'=>'share_image'),
					array('type'=>'string','title'=>'分享描述','name'=>'share_desc'),
				)
			),
			array(
				'title'=>'配送/自提设置',
					'list'=>array(
						array('type'=>'switch','title'=>'关闭快递配送？','name'=>'down_send_type1','help'=>'这里关闭后，全家禽，果树都关闭'),
						array('type'=>'switch','title'=>'关闭门店自取？','name'=>'down_send_type0','help'=>'这里关闭后，全家禽，果树都关闭'),
						array('type'=>'string','title'=>'默认配送费','name'=>'peisongfee'),
						array('name'=>'dispatchtype','title'=>'运费设置','type'=>'radio','options'=>'dispatchtype'),
						array('name'=>'template_id','title'=>'运费模版','type'=>'select','options'=>'dispatchid','show'=>array('dispatchtype'=>0),'help'=>'运费模板，统一调用商城体系的！'),
						array('name'=>'dispatchfee','title'=>'统一运费','type'=>'string','show'=>array('dispatchtype'=>1),'help'=>'统一运费后发往各地运费一致'),
						array('type'=>'array','name'=>'stores','add_tip'=>'添加一个自提门店',
							'list'=>array(
								array('type'=>'string','name'=>'title','title'=>'自提门店名称'),
								array('type'=>'string','name'=>'address','title'=>'自提门店地址'),
								array('type'=>'string','name'=>'name','title'=>'联系人'),
								array('type'=>'string','name'=>'mobile','title'=>'联系电话'),
							),
							'details'=>array(
								array('type'=>'string','name'=>'title','title'=>'自提门店名称'),
								array('type'=>'pcd','name'=>'pcd','title'=>'自提门店区域'),
								array('type'=>'lat_lng','name'=>'lat_lng','title'=>'门店坐标'),
								array('type'=>'string','name'=>'address','title'=>'自提门店地址'),
								array('type'=>'string','name'=>'name','title'=>'联系人'),
								array('type'=>'string','name'=>'mobile','title'=>'联系电话'),
							)
						)
					)
			),
			array(
				'title'=>'租赁时长',
					'list'=>array(
						array('type'=>'array','name'=>'times','add_tip'=>'添加一个土地租赁时长',
							'list'=>array(
								array('type'=>'string','name'=>'rent_time','title'=>'租赁时长'),
								
							),
							'details'=>array(
								array('type'=>'string','name'=>'rent_time','title'=>'租赁时长','help'=>'单位：天，只需填写数字'),
								
							)
						)
					)
			),
			array(
				'title'=>'幻灯片',
					'list'=>array(
						array(
							'type'=>'array',
							'name'=>'hdps',
							'add_tip'=>'添加一个幻灯片',
								'list'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片'),
									array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
									
								),
								'details'=>array(
									array('type'=>'image','name'=>'picurl','title'=>'幻灯片图片','help'=>''),
									array('type'=>'string','name'=>'url','title'=>'幻灯片链接'),
									
								)
						)
					)
			),
			array(
				'title'=>'板块导航',
					'list'=>array(
									array('type'=>'array','name'=>'bankuai','add_tip'=>'添加一个板块导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'image','name'=>'img','title'=>'导航图片'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'image','name'=>'img','title'=>'导航图片'),							
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
								),
					)
			),
			array(
				'title'=>'底部导航',

					'list'=>array(
									array('type'=>'updemo','name'=>'footernav','demo'=>'demofooternav','title'=>'重置导航','help'=>'不知道添加什么导航？重置默认的一下试试！'),
									array('type'=>'array','name'=>'footernav','add_tip'=>'添加一个底部导航',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),
										array('type'=>'string','name'=>'action','title'=>'导航链接'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'导航名称'),
										array('type'=>'icon','name'=>'icon','from'=>'jinyunicon','title'=>'导航图标'),							
										array('type'=>'link','name'=>'action','from'=>'action','title'=>'导航链接'),
									)
								),
					)
			),
			array(
				'title'=>'辅助应用',
					'list'=>array(
									array('type'=>'array','name'=>'plugins','add_tip'=>'添加一个辅助应用',
									'list'=>array(
										array('type'=>'string','name'=>'title','title'=>'应用名称'),
										array('type'=>'string','name'=>'desc','title'=>'应用描述'),
										array('type'=>'icon','name'=>'icon','title'=>'应用图标'),
										array('type'=>'string','name'=>'name','title'=>'应用标识'),							
									),
									'details'=>array(
										array('type'=>'string','name'=>'title','title'=>'应用名称'),
										array('type'=>'choose','op'=>'chooseplugins','name'=>'name','title'=>'应用标识','choose_title'=>'选择应用'),
										array('type'=>'icon','name'=>'icon','title'=>'应用图标'),							
										array('type'=>'string','name'=>'desc','title'=>'应用描述'),
									)
								),
					)
			),
		),
	);
	$return['dispatchtype']=array('0'=>'运费模板','1'=>'统一运费','2'=>'默认模板');
	$return['dispatchid']=pdo_getall('jy_weishop_dispatch',array('uniacid'=>$_SESSION['uniacid'],'status'=>1),array('id','title'),'id');
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='message_tpl'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$data=array_fields(array('confirm','cancel','tuikuan','disagree'),$postdata);
		$this->plugin_setting('message_tpl',$data);
		exi('设置成功');
	}
	$return['item']=$this->plugin_setting('message_tpl');
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'tabs'=>$tabs,
		'edit'=>array(
			array('type'=>'tip','title'=>'【温馨提示】：移步微信模板菜单，采用新型模板消息机制！'),
		),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='sms_tpl'){
	if($_RQ['postdata']){
		$postdata=get_postdata();
		$data=array_fields(array('notice'),$postdata);
		$this->plugin_setting('sms_tpl',$data);
		exi('设置成功');
	}
	$return['item']=$this->plugin_setting('sms_tpl');
	$htmls=array(
		'type'=>'edit',
		'desc'=>'参数设置',
		'tabs'=>$tabs,
		'edit'=>array(
			array('type'=>'tip','title'=>'【温馨提示】：移步短信库菜单，采用新型短信消息机制！'),
		),
	);
	$return['htmls']=$htmls;
	exi($return);
}
if($_RQ['op']=='chooseplugins'){
	$list = pdo_getall('core_plugins',array('hide'=>0),array('id','style','name','title','image','description'),'id');
	if($list){
		foreach($list as $k=>&$item){
			if(!check_permission($item['name'])){
				unset($list[$k]);
			}else{
				$item['plugininfo'] = array('name'=>$item['name'],'title'=>$item['title'],'description'=>$item['description']);
			}
			
		}
	}
	$return['list']=$list;
	$return['htmls']=array(
		'type'=>'list',
		'list'=>array('data'=>'list','edit'=>false,'delall'=>false,'del_one'=>false,'pagelist'=>false,'list'=>array(
			array('name'=>'title','title'=>'名称','type'=>'string'),
		),'action'=>array(
			array('type'=>'modal_result','name'=>'name','title'=>'选取'),
		)),
		'search_one'=>array('name'=>'title','add'=>false),
	);
	exi($return);
}

